package com.pratices.cookie.util;

import java.awt.*;
import java.awt.image.RenderedImage;
import java.io.FileOutputStream;

public class ImageSaver {
    public static void saveImage(Image image) {
         String fileName = "D:\\myPratices\\daydayup\\javaee\\src\\main\\resources\\Image";
        //把图片保存到本地
        try {
            FileOutputStream fos = new FileOutputStream(fileName);
            javax.imageio.ImageIO.write((RenderedImage) image, "png", fos);
            fos.close();
            System.out.println("图片保存成功！");
        } catch (Exception e) {
            System.out.println("图片保存失败！");
            e.printStackTrace();
        }

    }

    public static Image getImage(String image) {
        return Toolkit.getDefaultToolkit().getImage(image);
    }
}
